const { ipcRenderer } = require('electron')

function useIpcRenderer(actionMap) {
    Object.keys(actionMap).forEach((action) => {
        ipcRenderer.on(action, actionMap[action])
    })
    return () => {
        Object.keys(actionMap).forEach((action) => {
            ipcRenderer.removeListener(action)
        })
    }
}

export default useIpcRenderer